import { http } from "@/utils/http";
import { idpUrlApi } from "../utils";

export type searchPage = {
  hostname: string;
  ip: string;
  branchId: string;
  pageNum: number;
  pageSize: number;
};

export type Result = {
  list: Array<any>;
  total?: number;
};
// 获取设备分页
export const getPage = (params: searchPage) => {
  return http.request<Result>("get", idpUrlApi("client/page"), { params });
};
// 获取设备列表-全部可见列表穿梭框用的
export const getList = () => {
  return http.request<any[]>("get", idpUrlApi("client/list"));
};

export type searchLogDto = {
  logType: string;
  clientId: string;
};

// 获取采集详细信息
export const getLog = (params: searchLogDto) => {
  return http.request<any>("get", idpUrlApi("client/log"), { params });
};

export type clientBindBranchDto = {
  clientIds: string[];
  branchId: string;
};

// 设备分发
export const distributionClient = (data: clientBindBranchDto) => {
  return http.request("post", idpUrlApi("client/distribution"), { data });
};

// 获取未分发的设备分页
export const getFreeList = (params: searchPage) => {
  return http.request<Result>("get", idpUrlApi("client/freeList"), { params });
};

export type execPluginDto = {
  clientId: string;
  cmd: string;
  argus: string[];
};

// 执行插件
export const execPlugin = (data: execPluginDto) => {
  return http.request<string>("post", idpUrlApi("client/execPlugin"), { data });
};
